
var savedWord = "";

/**
 * Handles data sent via chrome.extension.sendRequest().
 * @param request Object Data sent in the request.
 * @param sender Object Origin of the request.
 * @param callback Function The method to call when the request completes.
 */
// Wire up the listener.
//chrome.extension.onRequest.addListener(onRequest);
chrome.extension.onRequest.addListener(function (request, sender, callback){
		//callback(window.getSelection());
		if(request.action.toString() == "getSelectedWord") {
			sel = window.getSelection();
			callback(sel.toString());
		} else if (request.action.toString() == "getSavedWord") {
			callback(savedWord.toString());
		} else if (request.action.toString() == "setSavedWord") {
			savedWord = request.word.toString();
		} else if (request.action.toString() == "resetSavedWord") {
			savedWord = "";
		}
	});

/* -- disabled for now
var beginShortcut = 0;
var keyCtrl = 17;
var keyM = 77;
function onKeyEvent(e) {
	if(e.which == keyCtrl) {
		beginShortcut = 1;
	} else if (e.which == keyM) {
		if(beginShortcut == 1) {
		}
		beginShortcut = 0;
	} else {
		beginShortcut = 0;
	}
}

window.addEventListener('keydown', onKeyEvent, false);
*/

